package com.example.meitu.api.controller;

import cn.hutool.json.JSON;
import com.example.meitu.api.common.Result;
import com.example.meitu.api.service.DictItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/dict")
@Slf4j
public class DictController {

    @Resource
    private DictItemService dictItemService;

    @GetMapping("/list")
    public Result list(@RequestParam(value = "code", required = true) String code){
        log.info("search dict item,code:{}",code);
        List<String> list = dictItemService.listByType(code);
        return Result.success(list);
    }

    @GetMapping("/listJson")
    public Result listJson(@RequestParam(value = "code", required = true) String code){
        log.info("search dict item,code:{}",code);
        List<JSON> list = dictItemService.listJson(code);
        return Result.success(list);
    }

}
